import java.util.StringTokenizer;


class ICPCP3279_7752 {

	public static void main(String[] args) {
		while (true) {
			String line = readLn();
			if ("# # #".equals(line)) break;
			StringTokenizer st = new StringTokenizer(line);
			String name1 = st.nextToken();
			int hits1 = 0;
			String name2 = st.nextToken();
			int hits2 = 0;
			
			String choice = st.nextToken();
			
			boolean even = "even".equals(choice);
			
			int numberOfThrows = Integer.parseInt(readLn());
			
			st = new StringTokenizer(readLn());
			
			for (int k = 0; k < numberOfThrows; k++) {
				int number = Integer.parseInt(st.nextToken());
				
				boolean numberB = (number % 2 == 0);
				
				if (even == numberB) hits2++;
				else hits1++;
				
			}
			
			System.out.println(name1 + " " + hits1 + " " + name2 + " " + hits2);
			
		}
	}
	
	static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuffer buffer = new StringBuffer();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char)car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
            System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) { return (null);}
        if ((car < 0) && (buffer.length() == 0)) return (null);
        return (buffer.toString()).trim();
    }

	
}
